package com.oracle.calllog.analyze.model;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class ComboKey extends BaseBean {
    //联系人属性
    private Contact contact = new Contact();
    // 日期维度属性
    // 日期维度分为三种情况:
    // 1.年份维度(年份数据正常,但月和日数据为-1)
    // 2.月份维度(年份月份数据正常,但日数据为-1)
    // 3.日份维度(年份月份日份数据都正常)
    private DateInfo dateInfo = new DateInfo();

    public ComboKey() {
        super();
    }

    public Contact getContact() {
        return contact;
    }

    public void setContact(Contact contact) {
        this.contact = contact;
    }

    public DateInfo getDateInfo() {
        return dateInfo;
    }

    public void setDateInfo(DateInfo dateInfo) {
        this.dateInfo = dateInfo;
    }

    @Override
    public int compareTo(BaseBean bean) {
        ComboKey anotherCom = (ComboKey) bean;

        int result = this.dateInfo.compareTo(anotherCom.dateInfo);
        if (result != 0)
            return result;

        result = this.contact.compareTo(anotherCom.contact);
        return result;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        contact.write(out);
        dateInfo.write(out);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        contact.readFields(in);
        dateInfo.readFields(in);
    }
}
